import { ref } from 'vue'
import { ElLoading } from 'element-plus'

export function useLoading() {
  const loadingInstance = ref<any>()
  return {
    showLoading(content: string) {
      loadingInstance.value = ElLoading.service({
        lock: true,
        text: content,
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })
    },
    // 关闭遮罩层
    closeLoading() {
      loadingInstance.value.close()
    },
  }
}
